package cn.bonoon.kernel.menus.tips;

import org.batatasframework.web.RequestParameterReader;

import cn.bonoon.kernel.menus.AbstractMenuable;
import cn.bonoon.kernel.menus.PlatformContext;
import cn.bonoon.kernel.support.IOperator;

public abstract class AbstractMenuTipHandler implements MenuTipHandler{
	
	protected PlatformContext platformContext;
	protected AbstractMenuable menu;
	protected MenuTipArguments argument;
	
	@Override
	public final void init(PlatformContext platformContext, AbstractMenuable menu, MenuTipArguments argument) throws Exception {
		this.platformContext = platformContext;
		this.menu = menu;
		this.argument = argument;
		
		internalInit();
	}
	
	protected void internalInit() throws Exception { }
	
	@Override
	public final MenuTipResult handle(IOperator operator, RequestParameterReader reader) throws Exception {
		MenuTipResult result = new MenuTipResult(menu, argument);
		
		internalHandler(operator, reader, result);
		
		return result;
	}
	
	protected void internalHandler(IOperator operator, RequestParameterReader reader, MenuTipResult result) throws Exception{
		
	}
}
